<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output method='xml'
	indent="yes"
	omit-xml-declaration="yes"
	doctype-public = "-//W3C//DTD XHTML 1.0 Strict//EN"
	doctype-system = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
	/>


<!-- includes -->
<xsl:include href="admin_template.xsl"/>

<!-- parameters -->
<xsl:param name="_user_level"/>

<!-- form data + error handling -->
<xsl:param name="_id"/>

<xsl:param name="_name"/>
<xsl:param name="_name_empty_error"/>
<xsl:param name="_token"/>
<xsl:param name="_token_empty_error"/>
<xsl:param name="_token_valid_error"/>
<xsl:param name="_imagecode"/>
<xsl:param name="_imagecode_empty_error"/>
<xsl:param name="_imagecode_valid_error"/>
<xsl:param name="_image"/>
<xsl:param name="_account_authenticated"/>


<xsl:template match="/">
<html>

<!-- html head -->
<xsl:call-template name="admin_head">
	<xsl:with-param name="_title">Login</xsl:with-param>
</xsl:call-template>


<body>
	<!-- content -->
<div id="admin_content_div">

<!-- display form -->
<xsl:if test= "($_account_authenticated)!='true'">

	<div id="auth_form_div">

		<!-- error list -->
		<xsl:if test="$_name_empty_error"><li>Please fill the name field</li></xsl:if>
		<xsl:if test="$_token_empty_error"><li>Please fill the password field</li></xsl:if>
		<xsl:if test="$_token_valid_error"><li>Invalid password</li></xsl:if>
		<xsl:if test="$_imagecode_empty_error"><li>Please fill the image code field</li></xsl:if>
		<xsl:if test="$_imagecode_valid_error"><li>Invalid image code</li></xsl:if>

		<form method="post" enctype="multipart/form-data">

										<!-- name field -->
										<p id="auth_form_p">
											<label id="auth_form_label" for="real_name">Name:</label>
											<input type="text" name="name" id="admin_form_textfield">
												<xsl:attribute name="value">
													<xsl:value-of select="$_name"/>
												</xsl:attribute>
												<xsl:if test="$_name_empty_error">
													<xsl:attribute name="id">admin_form_textfield_error</xsl:attribute>
												</xsl:if>
											</input>
										</p>

										<!-- password field -->
										<p id="auth_form_p">
											<label id="auth_form_label" for="token">Password:</label>
											<input type="password" name="token" id="admin_form_textfield">
												<xsl:attribute name="value">
													<xsl:value-of select="$_token"/>
												</xsl:attribute>
												<xsl:if test="$_token_empty_error">
													<xsl:attribute name="id">admin_form_textfield_error</xsl:attribute>
												</xsl:if>
												<xsl:if test="$_token_valid_error">
													<xsl:attribute name="id">admin_form_textfield_error</xsl:attribute>
												</xsl:if>
											</input>
										</p>

										<!-- image -->
										<div id="image code">
											<img id="img_code">
												<xsl:attribute name="src"><xsl:value-of select="$_image"/></xsl:attribute>
											</img>
											<input type="hidden" name="image">
												<xsl:attribute name="value">
													<xsl:value-of select="$_image"/>
												</xsl:attribute>
											</input>
										</div>

										<!-- image code field -->
										<p id="admin_form_p">
											<label id="admin_form_label" for="desc">Imagecode:</label>
											<input type="text" name="imagecode" id="admin_form_textfield">
												<xsl:attribute name="value">
													<xsl:value-of select="$_imagecode"/>
												</xsl:attribute>
												<xsl:if test="$_imagecode_empty_error">
													<xsl:attribute name="id">admin_form_textfield_error</xsl:attribute>
												</xsl:if>
												<xsl:if test="$_imagecode_valid_error">
													<xsl:attribute name="id">admin_form_textfield_error</xsl:attribute>
												</xsl:if>
											</input>
										</p>


										<!-- buttons -->
										<p id="admin_buttons_p">
											<input type="hidden" name="form_posted" value="posted"/>
											<input type="submit" value="Log in" id="admin_form_button"/>
										</p>

		</form>
	</div>
</xsl:if>

<xsl:if test= "($_account_authenticated)!='false'">
	<h3>Successfull login.</h3>
	<strong>Name: </strong><xsl:value-of select="$_name"/><br/>
	<a>
		<xsl:attribute name="href">index.php?op=manage</xsl:attribute>Back
	</a>
</xsl:if>
</div>

</body>
</html>
</xsl:template>

</xsl:stylesheet>
